package test3.main;

import test3.bean.Employee;
import test3.controller.PageController;
import test3.controller.impl.PageControllerImpl;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

import javax.swing.JOptionPane;

public class QueryAllAction implements ActionListener {

	Index index;
	
	public QueryAllAction(Index in) {
		index = in;
	}

	private PageController controller = new PageControllerImpl();
	
	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		String select = e.getActionCommand();
		if(select == "submit") {

			//得到所有的数据
			List<Employee> employees=controller.showEmployees();

			System.out.println("QUERY ALL");
			System.out.println(employees);
			//对数据的显示
			//

			Toolkit.getDefaultToolkit().beep();
			JOptionPane.showMessageDialog(null, "Query failure","Result",JOptionPane.PLAIN_MESSAGE);
		}
		else {
			index.card.show(index.panel, "welcome");
		}
	}

}
